<template>
  <div class="container spread-container" :style="style">
    <div class="spread-tips">
      <h1>{{message}}</h1>
      <h2>{{cash}}</h2>

    </div>
    <div class="spread-action">
      <van-button
        size="large"
        round
        @click="onSubmit"
        :disabled="disableSubmit"
      >立即下载APP开启您的购物之旅</van-button>

      <van-divider>{{guide}}</van-divider>
    </div>
  </div>
</template>

<script>
import { openApp } from '../../common/util'
import {
  Row,
  Col,
  Cell,
  Button,
  CellGroup,
  Field,
  Area,
  Icon,
  Image,
  Divider,
  Popup,
  Picker
} from 'vant'

export default {
  components: {
    [Row.name]: Row,
    [Col.name]: Col,
    [Cell.name]: Cell,
    [Button.name]: Button,
    [CellGroup.name]: CellGroup,
    [Field.name]: Field,
    [Area.name]: Area,
    [Icon.name]: Icon,
    [Popup.name]: Popup,
    [Image.name]: Image,
    [Divider.name]: Divider,
    [Picker.name]: Picker,
    openApp
  },
  data () {
    return {
      disableSubmit: false,
      cash: '￥14.90',
      message: '领取成功，现金券已入账',
      guide: '下载后使用领取的手机号注册用户下单即可使用',
      style: {
        backgroundImage: 'url(' + require('../../assets/images/bg/spreadsuccess.jpg') + ')'
      }
    }
  },

  created () {},
  computed: {
    uniqueSignedDates () {
      return this.arrayUnique(this.signedDates)
    }
  },
  watch: {
    todayAction: {
      handler (val, oldVal) {
        if (val.date !== oldVal.date) {
          this.signedDates.push(val.date)
        }
      },
      deep: true
    }
  },
  methods: {
    onSubmit () {
      openApp(res => {
        this.$router.replace({
          name: 'download'
        })
      })
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="less" scoped>
.spread-container {
  background-repeat: no-repeat;
  background-position: top center;
  background-size: cover;
  background-color: #f35647;
  padding: 20vh 15px 0;
}
.spread-tips {
  text-align: center;
  padding: 20px 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  > * {
    padding: 20px 0;
    color: #fff;
    position: relative;
    z-index: 1;
    margin: 0;
    &::before {
      position: absolute;
      left: 50%;
      top: 0;
      height: 100%;
      width: 10px;
      margin-left: -5px;
      content: "";
      background: #f45748;
      z-index: -1;
    }
  }
  h1 {
    font-size: 18px;
    padding-bottom: 30px;
  }

  h2 {
    display: inline-block;
    border-radius: 5px;
    height: 50px;
    padding: 0 10px;
    font-size: 32px;
    border: 1px dotted #fff;
    &::after {
      position: absolute;
      left: 0;
      top: 0;
      height: 100%;
      width: 100%;
      content: "";
      background: rgba(255, 255, 255, 0.2);
    }
  }
}
.spread-action {
  position: fixed;
  left: 0;
  bottom: 30px;
  width: 100%;
  padding: 20px;
  text-align: center;
  .van-divider {
    color: #aaa;
    font-weight: 300;
    margin: 25px 0 0;
    font-size: 12px;
  }
  .van-button {
    background: transparent;
    border-color: #f35647;
    color: #f35647;
    text-transform: uppercase;
    width: auto;
    padding-left: 15px;
    padding-right: 15px;
  }
}
</style>
